package exercise5;
import java.util.Scanner;
public class Diagonal extends BaseExample {
	
	public  void printDiagnal() {
		
			@SuppressWarnings("resource")
			Scanner in = new Scanner(System.in);
			this.logger.debug("请输入二维数组的长度：");
			int n = in.nextInt();
			int[][] arr = new int[n][n];
			int sum = 0;
			this.logger.debug("请输入数组的元素：");
			for (int i = 0; i < arr.length; i++) {
				for (int j = 0; j < arr.length; j++) {
					arr[i][j] = in.nextInt();
					if (i == j) {
						sum+=arr[i][j];
					}
				}
			}
			
			this.logger.debug("数组额对角线之和为："+sum);
		}
}
